package interrupt;

/**
 * 线程的中断操作
 */
public class InterruptDemo implements Runnable {

    @Override
    public void run() {
        //判断 当前线程是否已经中断
        while (!Thread.currentThread().isInterrupted()) {
            System.out.println("你好世界");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new InterruptDemo());
        thread.start();
        Thread.sleep(3000);
        thread.interrupt();
    }
}
